<template>
	<view class="content">
		<view :class="show ? 'fade-in' : 'fade-out'">
			<view class="top">
				<view class="user">
					<image :src="user.avatar" mode=""></image>
					<view class="name-id">
						<text class="name">{{user.nickname}}</text>
						<text class="id">ID:{{user.user_id}}</text>
					</view>
				</view>
				<view class="list">
					<text class="label">性别：</text>
					<text class="value">{{user.sex == 1 ? '男生' : '女生'}}</text>
				</view>
				<view class="list">
					<text class="label">价格：</text>
					<text class="value">{{user.min_price}}-{{user.max_price}}</text>
				</view>
				<view class="list">
					<text class="label">局数：</text>
					<text class="value">{{user.exp_num}}</text>
				</view>
				<view class="list">
					<text class="label">派单时间：</text>
					<text class="value">{{user.create_time}}</text>
				</view>
				<view class="list">
					<text class="label">其他要求：</text>
					<text class="value">{{user.other}}</text>
				</view>
			</view>
			<view class="btn" @click="submit">取消派单</view>
			<modal ref="modal" rightTex="确定" content="是否确认取消发布？" @confirm="confirm"></modal>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				user: '',
				show: false
			}
		},
		onLoad(option) {
			this.id = option.id
			this.getuser()
		},
		methods: {
			async getuser() {
				try {
					let result = await this.$request({
						loading: 1,
						method: 'post',
						url: '/api/play_matching/user_matching_info',
						data: {
							play_matching_id: this.id
						}
					})
					console.log(result)
					this.user = result.data.data
					this.show = true
				} catch (e) {
					//TODO handle the exception
				}
			},
			submit() {
				this.$refs.modal.open()
			},
			async confirm(){
				try {
					let result = await this.$request({
						loading: 1,
						method: 'post',
						url: '/api/play_matching/user_cancel',
						data: {
							play_matching_id:this.id
						}
					})
					this.$refs.modal.close()
					this.msg(result.data.msg)
					setTimeout(() =>{
						uni.navigateBack({delta:1})
					},800)
				} catch (e) {
					this.msg(e.data.msg)
					//TODO handle the exception
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 30rpx;

		.top {
			background-color: #211C3A;
			border-radius: 20rpx;
			padding: 24rpx;

			.user {
				display: flex;
				align-items: center;

				image {
					width: 98rpx;
					height: 98rpx;
					border-radius: 50%;
				}

				.name-id {
					color: #FFFFFF;
					display: flex;
					flex-direction: column;
					padding-left: 24rpx;

					.name {
						font-size: 32rpx;
						font-weight: 500;
						color: #FFFFFF;
					}

					.id {
						font-size: 24rpx;
						font-weight: 500;
						color: #FFFFFF;
						margin-top: 8rpx;
					}
				}
			}

			.list {
				font-size: 30rpx;
				margin-top: 20rpx;

				.label {
					color: #999999;
				}

				.value {
					color: #FFFFFF;
				}
			}
		}

		.btn {
			height: 88rpx;
			background: linear-gradient(180deg, #DB89F5 0%, #834BF4 100%);
			border-radius: 20rpx;
			font-size: 32rpx;
			font-weight: 500;
			color: #FFFFFF;
			text-align: center;
			line-height: 88rpx;
			margin-top: 32rpx;
		}
	}
</style>